<%@ page language="java" contentType="text/html; charset=utf8"%>
<%@page import="com.testingedu.jdbcDao.TTrainInfoDao"%>
<%@page import="com.testingedu.model.TResource"%>
<%@page import="com.testingedu.model.TTrainInfo"%>
<%@page import="com.testingedu.common.QueryResult"%>
<%@page import="com.testingedu.utils.StringUtils"%>
<%@page import="java.util.*"%>
<%@page import="com.testingedu.model.TIndexPicture"%>
<%@page import="com.testingedu.jdbcDao.TIndexPictureDao"%>
<%QueryResult queryResult  = (QueryResult)request.getAttribute("queryResult"); %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>网络测试培训网-国内首家专注网络自动化测试_手动测试培训网站</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

		<meta name="description"
			content="网络测试培训网-国内首家专注网络自动化测试_手动测试培训网站,提供网络测试培训,自动化测试培训,手动测试培训,云测试培训服务." />
		<meta name="keywords" content="网络测试培训,自动化测试培训,手动测试培训,云测试培训" />
		<link rel="icon" href="${pageContext.request.contextPath}/favicon.ico" type="image/x-icon"/>
		<link rel="shortcut icon" href="${pageContext.request.contextPath}/favicon.ico"  type="image/x-icon"/>
		<link href="${pageContext.request.contextPath}/css/reset.css"
			rel="stylesheet" type="text/css" />
		<link href="${pageContext.request.contextPath}/css/default.css"
			rel="stylesheet" type="text/css" />
		<link href="${pageContext.request.contextPath}/css/style.css"
			rel="stylesheet" type="text/css" />
		<script type="text/javascript"
			src="${pageContext.request.contextPath}/js/jquery-1.7.2.js">
</script>
<script type="text/javascript"
			src="${pageContext.request.contextPath}/js/jquery.leanModal.min.js">
</script>
		<script type="text/javascript"
			src="${pageContext.request.contextPath}/js/utils.js">
</script>
		<script type="text/javascript">
$(function() {
	var sWidth = $("#focus").width();
	var len = $("#focus ul li").length;
	var index = 0;
	var picTimer;
	var btn = "<div class='btnBg'></div><div class='btn'>";
	for ( var i = 0; i < len; i++) {
		btn += "<span>" + (i + 1) + "</span>";
	}
	btn += "</div>"
	$("#focus").append(btn);
	$("#focus .btnBg").css("opacity", 0);
	$("#focus .btn span").mouseenter(function() {
		index = $("#focus .btn span").index(this);
		showPics(index);
	}).eq(0).trigger("mouseenter");
	$("#focus ul").css("width", sWidth * len);
	$("#focus ul li div").hover(function() {
		$(this).siblings().css("opacity", 0.7);
	}, function() {
		$("#focus ul li div").css("opacity", 1);
	});
	$("#focus").hover(function() {
		clearInterval(picTimer);
	}, function() {
		picTimer = setInterval(function() {
			showPics(index);
			index++;
			if (index == len) {
				index = 0;
			}
		}, 5000);
	}).trigger("mouseleave");
	function showPics(index) {
		var nowLeft = -index * sWidth;
		$("#focus ul").stop(true, false).animate( {
			"left" : nowLeft
		}, 1000);
		$("#focus .btn span").removeClass("on").eq(index).addClass("on");
	}
});
</script>
<script type="text/javascript">
$(document).ready(function() {
	//$('#aOpen').leanModal({ top: 100, closeButton: ".modal_close" });
		$('a[rel*=leanModal]').leanModal( {
			top : 100,
			closeButton : ".modal_close"
		});
	});
function modal_() {
	$('#lean_overlay').css('display', 'none');
	$('#OpenWindow').css('display', 'none');
	$('#_login_error_msg').remove();
}
</script>
	</head>
	<body>
		<div id="header">
			<div class="tlink">
				<div class="logo">
				</div>
				<div class="navs">
					<ul class="ul">
						<%if(session.getAttribute("testingedu_user") != null ) {%>
						<li>
							<a href="#">您已登陆</a>
						</li>
						<%} else {%>
						<li>
							<a id="aOpen" href="#OpenWindow" rel="leanModal">用户登陆</a>
							<a href="#" style="display: none" id="_login_yes">您已登陆</a>
						</li>
						<%} %>
						<li>
							<a href="javascript:addBookmark()">加入收藏</a>
						</li>
						<li>
							<a href="javascript:setHome()">设为首页</a>
						</li>
						<li>
							<a href="#">合作咨询</a>
						</li>
						<li>
							<a href="#">关于我们</a>
						</li>
					</ul>
					<div class="menu">
						<ul>
							<li class="index">
								<a href="${pageContext.request.contextPath}">首页</a>
							</li>
							<li class="split">
								&nbsp;
							</li>
							<li>
								<a
									href="${pageContext.request.contextPath}/resource/list">培训资料</a>
							</li>
							<li class="split">
								&nbsp;
							</li>
							<li>
								<a
									href="${pageContext.request.contextPath}/news/list?category_name=课程安排">课程安排</a>
							</li>
							<li class="split">
								&nbsp;
							</li>
							<li>
								<a
									href="${pageContext.request.contextPath}/news/list?category_name=培训大纲">培训大纲</a>
							</li>
							<li class="split">
								&nbsp;
							</li>
							<li>
								<a
									href="${pageContext.request.contextPath}/news/list?category_name=认证大纲">认证大纲</a>
							</li>
							<li class="split">
								&nbsp;
							</li>
							<li>
								<a href="${pageContext.request.contextPath}/teacher/list">教师队伍</a>
							</li>
							<li class="split">
								&nbsp;
							</li>
							<li>
								<a
									href="${pageContext.request.contextPath}/news/list?category_name=就业动态">就业动态</a>
							</li>
							<li class="split">
								&nbsp;
							</li>
							<li>
								<a href="${pageContext.request.contextPath}/contact.jsp">在线报名</a>
							</li>
						</ul>
					</div>
				</div>
			</div>
		</div>
		<div class="banner">
			<div id="focus" style="width: 960px">
				<ul>
					<%List<TIndexPicture> pics = TIndexPictureDao.index(6);
						for(TIndexPicture pic : pics) {%>
					<li style="background-color: white;">
						<div style="left: 0; top: 0; width: 960px; height: 222px;">

							<a href=""><img
									src="${pageContext.request.contextPath}/<%=pic.getPath() %>" title="<%=pic.getName() %>"/>
							</a>
						</div>
					</li>
					<%} %>
				</ul>
			</div>
		</div>
		<div id="body">
			<div class="grayspace">

			</div>
			<div class="left">
				<div id="newlist">
					<ul>
						<%for(int i=0;i < queryResult.getResultList().size();i++) {
						TResource tResource = (TResource) queryResult.getResultList().get(i);%>
						<li>
							<a
								href='${pageContext.request.contextPath}/news/info?id=<%=tResource.getId() %>'
								class='preview'><img
									src='${pageContext.request.contextPath}/images/defaultpic.gif' />
							</a>
							<a
								href="${pageContext.request.contextPath}/resource/info?id=<%=tResource.getId() %>"
								class="title"><%=tResource.getName() %></a>
							<%if("n".equals(tResource.getIsPri())) {%>
							<a class="download"
								href="javascript:download(<%="y".equals(tResource.getIsLocal()) ? 1 : 2 %>,<%=tResource.getId() %>);">立即下载</a>
							<%} else {%>
								<a class="download"
								href="javascript:pri_download(<%="y".equals(tResource.getIsLocal()) ? 1 : 2 %>,<%=tResource.getId() %>);">立即下载</a>
							<%}%>
							<span class="info"> <small>日期：</small><%=tResource.getAddTime() %></span>
							<p class="intro">
								...
							</p>
						</li>
						<%} %>
					</ul>
					<div class="dede_pages">
						<ul class="pagelist">
							<li>
								<span class="pageinfo">共 <strong><%=queryResult.getAllPage() %></strong>页<strong><%=queryResult.getAllCount() %></strong>条记录</span>
							</li>

						</ul>
					</div>
				</div>
			</div>

			<div class="right">
				<div class="news">
					<div class="title">
						<img src="${pageContext.request.contextPath}/images/title_ico.gif" />
						培训资讯
					</div>
					<div class="line">
					</div>
					<ul>
						<%List<TTrainInfo> ts = TTrainInfoDao.index(6);
                for(int i = 0; i < ts.size(); i++){
                	TTrainInfo tTrainInfo = ts.get(i);
                	if( "2".equals(tTrainInfo.getLevel()) ) {%>
						<li>
							<a
								href="${pageContext.request.contextPath}/news/info?id=<%=tTrainInfo.getId() %>" title="<%=StringUtils.substring(tTrainInfo.getTitle(), 17) %>"><font
								color='#006600'><%=StringUtils.substring(tTrainInfo.getTitle(), 17) %></font>
							</a>
						</li>
						<li class="split">
						</li>
						<%} else {
                		if("3".equals(tTrainInfo.getLevel())) {%>
						<li>
							<a
								href="${pageContext.request.contextPath}/news/info?id=<%=tTrainInfo.getId() %>" title="<%=StringUtils.substring(tTrainInfo.getTitle(), 17) %>"><font
								color='#FF0000'><%=StringUtils.substring(tTrainInfo.getTitle(), 17) %></font>
							</a>
						</li>
						<li class="split">
						</li>
						<%} else {%>
						<li>
							<a
								href="${pageContext.request.contextPath}/news/info?id=<%=tTrainInfo.getId() %>" title="<%=StringUtils.substring(tTrainInfo.getTitle(), 17) %>"><%=StringUtils.substring(tTrainInfo.getTitle(), 17) %></a>
						</li>
						<li class="split">
						</li>
						<%}
                	}
                }%>
					</ul>
				</div>
				<div class="blogs">
					<div class="title">
						<img src="${pageContext.request.contextPath}/images/title_ico.gif" />
						专家博客
					</div>
					<div class="line">
					</div>
					<ul>
						<li>
							<a href="http://www.jacktesting.com/blog/author/steven-li">steven-li</a>
						</li>
						<li class="split">
						</li>
						<li>
							<a href="http://www.jacktesting.com/blog/author/style">style</a>
						</li>
						<li class="split">
						</li>

					</ul>
				</div>

				<div class="sigmaca">
					<div class="title">
						<img src="${pageContext.request.contextPath}/images/title_ico.gif" />
						Signma证书
					</div>
					<div class="line">
					</div>
					<div class="ca">

					</div>
				</div>
				<div class="contactus">
					<div class="title">
						<img src="${pageContext.request.contextPath}/images/title_ico.gif" />
						联系方式
					</div>
					<div class="line">
					</div>
					<div class="tel">
						<div>
						</div>
						<ul>
							<li>
								QQ:
								<strong>7607960</strong>
							</li>
							<li>
								电话:
								<strong>028-61404760</strong>
							</li>
						</ul>
					</div>
				</div>
			</div>
		</div>
		<div class="footer">
			<div class="copyright">
				<a href="#">关于测试培训</a> |
				<a href="#">培训流程</a> |
				<a href="#">培训服务</a> |
				<a href="#">联系我们</a> |
				<a href="#">网站地图</a>
				<br />
				<p>
					版权所有：
					<a href="http://www.testingedu.com">网络测试培训</a> CopyRight©2009-2012
					www.testingedu.com
					<!--  <script src="http://s19.cnzz.com/stat.php?id=2922258&web_id=2922258&show=pic" language="JavaScript"></script>
-->
				</p>
			</div>
		</div>
		<div id="OpenWindow">
			<div id="signup-ct">
				<div id="OpenWindow-header">
					<p>
						用户登录界面
					</p>
					<a href="javascript:modal_()" class="modal_close"></a>
				</div>
				<form action="" method="post" id="_login_form">
					<div class="txt-fld">
						<label for="">
							用户名
						</label>
						<input type="text" name="account" class="good_input" id="_account" />
					</div>
					<div class="txt-fld">
						<label for="">
							密码
						</label>
						<input type="password" name="password" id="_password" />
					</div>
					<div class="btn-fld">
						<button type="button" onclick="user_to_login();">
							登陆 »
						</button>
					</div>
				</form>
			</div>
		</div>
		<script type="text/javascript">
		var type=0;
		var id=0;
function download(type, id) {
	if (type == 1) {
		window.location.href = "${pageContext.request.contextPath}/resource/download?id="+id;
	}
	else {
		if (type == 2) {
			$.ajax( {
						type : "POST",
						url : "${pageContext.request.contextPath}/resource/download?id="+id,
						dataType : "json",
						success : function(json) {
							if (json.uri) {
								window.location.href = json.uri;
							} else {
								alert("下载过程中出现了错误，请重试");
							}
						},
						error : function(XMLHttpRequest, textStatus,
								errorThrown) {
							alert("登陆时发生了错误，请重试");
						}
					});
		}
	}
}

function pri_download(type, id) {
	$.ajax( {
				type : "POST",
				url : "${pageContext.request.contextPath}/user/isLogin",
				dataType : "json",
				success : function(json) {
					if (json.login == 'yes') {
						download(type, id);
					} else {
						setType(type);
						setId(id);
						$('a[rel*=leanModal]').click();
						$('#OpenWindow-header')
								.append(
										'<p align="center" id="_login_error_msg" style="color:red">您还没有登录，请先登陆</p>');
						alert($('#_login_error_msg').html());
					}
				},
				error : function(XMLHttpRequest, textStatus, errorThrown) {
					alert("登陆时发生了错误，请重试");
				}
			});
}
function user_to_login() {
	var account = $('#_account').val();
	if(account.length < 3 || account.length > 20) {
		if($('#_login_error_msg').val() == null)
     		$('#OpenWindow-header').append('<p align="center" style="color:red" id="_login_error_msg">登录名长度不正确，应该在3-20位之间</p>');
     	else {
     		$('#_login_error_msg').text('登录名长度不正确，应该在3-20位之间');
     	}
		return;
	}
	var password = $('#_password').val();
	if(password.length < 3 || password.length > 20) {
		if($('#_login_error_msg').val() == null)
     		$('#OpenWindow-header').append('<p align="center" style="color:red" id="_login_error_msg">密码长度不正确，应该在3-20位之间</p>');
     	else {
     		$('#_login_error_msg').text('密码名长度不正确，应该在3-20位之间');
     	}
		return;
	}
	$.ajax( {
				type : "POST",
				url : "${pageContext.request.contextPath}/user/login",
				data : $('#_login_form').serialize(),
				dataType : "json",
				success : function(json) {
					if (json.msg != 'null') {
						if($('#_login_error_msg').val() == null)
     						$('#OpenWindow-header').append('<p align="center" style="color:red" id="_login_error_msg">'+json.msg+'</p>');
						else {
							$('#_login_error_msg').text(json.msg);
						}
					} else {
						if (json.id > 0) {
							modal_();
							$('#_login_yes').css('display', 'block');
							$('#aOpen').remove();
							$('#password').attr('value', '');
							if(getType() > 0 && getId() > 0) {
								pri_download(getType(),getId());
							}
						}
					}
				},
				error : function(XMLHttpRequest, textStatus, errorThrown) {
					alert("登陆时发生了错误，请重试");
				}
			});
}
function setType(type) {
	this.type=type;
}
function setId(id) {
	this.id = id;
}
function getType() {
	return type;
}
function getId() {
	return id;
}
</script>
	</body>
</html>